package com.panpay.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

@WebServlet("/date")
public class DateServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html; charset=UTF-8");
//        存储数据 创建时间，当前系统时间
        req.setAttribute("createTime", new Date());
//       转发   转发到template目录下的f01文件（该文件必须先存在）
        req.getRequestDispatcher("template/freeDate.ftl").forward(req, resp);
    }
}
